<?php
/**
 * Created by PhpStorm.
 * User: Tomkk
 * Date: 2016/5/5
 * Time: 16:03
 */
require "utils/conn.php";

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$user = $request->user;
$username = $user->username;
$password = $user->password;
$role = $user->role;
if($role == 0){//0 表示管理员
    $sql = "SELECT 1 FROM php.admins WHERE admin_name='$username' AND admin_pwd='$password'";
}else{
    $sql = "SELECT 1 FROM php.user WHERE user_name='$username' AND password='$password'";
}
if(mysqli_num_rows(mysqli_query($mysqli,$sql))){
    die(success(0,$username));
}else{
    die(error(2,"账号或者密码错误"));
}
